import React, { Component } from 'react'
import './VideoDetail.css';
import axios from 'axios';

export default class VideoDetail extends Component {
    //状态声明
    state = {
        data: {}//强烈建议 使用『{}』
    }
    render() {
        //解构赋值
        let {desc, video_local} = this.state.data;
        console.log(video_local);
        return (
            <div className="detail-container">
                <h2>{desc}</h2>
                <div className="video-container">
                    <video
                     controls
                     src={'http://cdn.xiaohigh.com' + video_local}>
                     </video>
                </div>
            </div>
        )
    }

    async componentDidMount(){
        //声明一个 id
        let id = 20;
        //发送请求
        let result = await axios('http://api.xiaohigh.com/douyin/' + id); 
        //获取结果
        let data = result.data;
        this.setState({
            data: data
        })
    }
}
